﻿
@using Shop.Entity;
@using Shop.Help;
@using Shop.Bll;
@using System.Data;
@using Webdiyer.WebControls.Mvc;
@{
    Layout = null;
    string actionString = RoleLogic.GetPowerStr("MemberCategory", ManagerLogic.GetLoginInfo().ManagerRoleGuid);
}
@model  PagedList<DataRow>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>列表</title>
    <link href="~/Content/admin/css/bootstrap.min.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/MvcPager/MvcPager.js"></script>
    <script src="~/Content/LwsJS/List.js"></script>

    <style>
        .pibarea {
            float: left;
            margin-left: 2em;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <ol class="breadcrumb">
            <li><a href="/set/admin/center">首页></a></li>
            <li><a href="#">会员管理></a></li>
            <li class="active">会员级别</li>
        </ol>

        <div class="portlet-body">
            <div class="navbar-form navbar-left" style="padding:0px;" role="search">
                @if (actionString.Contains("Add"))
            {
                    <a class="btn btn-primary btn-sm " data-toggle="modal" href="/member/membercategory/add"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;新增</a>
                }
            </div>
            <form class="navbar-form navbar-left" id="formSearch" role="form" action="/Member/MemberCategory/List">
                <input type="hidden" name="PageSize" value="10" />
                <div class="form-group">
                    <input type="text" class="form-control input-sm" id="SearchTitle" name="title" placeholder="请输入标题" />
                </div>
                <button type="submit" class="btn btn-primary btn-sm ">
                    <span class="glyphicon glyphicon-zoom-in" aria-hidden="true"></span>&nbsp;搜索
                </button>
            </form>
            <div id="divTable">
                <table class="table table-bordered  table-condensed table-condensed  table-hover table-condensed">
                    <thead>
                        <tr>
                            <th>标题</th>
                            <th>售价</th>
                            <th>初始积分</th>
                            <th>初始余额</th>
                            <th>推荐分成</th>
                            <th>升级积分点</th>
                            <th class="hidden-xs">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var row in Model)
                        {
                            <tr>
                                <td class="title">
                                    @row["Title"]
                                </td>
                                <td>@row["SoldMoney"] 元</td>
                                <td>@row["DefaultPoint"] 分 </td>
                                <td>@row["DefaultValue"] 分</td>
                                <td>@row["RecommendPoint"] 分</td>
                                <td>@row["UpgradeNeedPoint"] 分</td>
                                <td>
                                    @if (actionString.Contains("Edit"))
                                    {
                                        <a class="btn btn-default btn-xs" title='编辑信息' href="/Member/MemberCategory/add/@row["Guid"]?pageIndex=@Model.CurrentPageIndex">编辑</a>
                                    }
                                    @if (actionString.Contains("Delete"))
                                    {
                                        <a class="btn btn-default btn-xs" title='' onclick="Delete('@row["Guid"]','/Member/MemberCategory/delete','/Member/MemberCategory/list/@(Model.CurrentPageIndex - 1 > 1 ? Model.CurrentPageIndex - 1 : 1)');">删除 </a>
                                    }
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                <div class="col-xs-9" style="width:auto;padding-left:0px;">
                    <input type="hidden" value="@Model.TotalPageCount" id="TotalPageCount" />
                    <ul class="pagination">
                        <li>
                            <span aria-hidden="true">
                                @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
                            </span>
                        </li>
                        <li>
                            <span aria-hidden="true">
                                每页
                                <select style="border-radius:4px;font-family:normal;vertical-align: text-bottom;" id="PageSize" name="PageSize" onchange="PageSizeChange();">
                                    <option value="10">10</option>
                                    <option value="15">15</option>
                                    <option value="20">20</option>
                                </select>
                                条
                            </span>
                        </li>
                    </ul>
                    @Ajax.Pager(Model,
new PagerOptions
{
    PageIndexParameterName = "id",
    CssClass = "pagination",
    FirstPageText = "首页",
    LastPageText = "尾页",
    PrevPageText = "上一页",
    PageIndexBoxId = "pageIndexBox",
    NextPageText = "下一页",
    CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
    DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
    PagerItemTemplate = "<li>{0}</li>",
    AutoHide = false,

}, new MvcAjaxOptions
{
    UpdateTargetId = "divTable",
    HttpMethod = "Post",
    DataFormId = "formSearch",
    EnableHistorySupport = false,
    OnSuccess = "Success()",
    EnablePartialLoading = true
}
)
                    <ul class="pagination" style="width:20%;margin-top: 0px;">
                        <li>
                            <div class="input-group">
                                <span class="input-group-addon">第</span>
                                <input type="text" id="pageIndexBox" class="form-control input-sm" placeholder="" aria-describedby="sizing-addon2" oninput="InputPageIndex(this);">
                                <span class="input-group-addon">页</span>
                                <span class="input-group-btn">
                                    <button class="btn btn-primary btn-sm" type="button">GO</button>
                                </span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        @section Scripts{@{Html.RegisterMvcPagerScriptResource();}
        }
    </div>
    <script type="text/javascript">
        function InputPageIndex(obj)
        {
            var pageIndex = $(obj).val().trim();
            if (parseInt(pageIndex) > parseInt($("#TotalPageCount").val()))
            {
                $(obj).val($("#TotalPageCount").val());
            }
        }
        function PageSizeChange()
        {
            $("input[name='PageSize']").val($("#PageSize").val());
            $("#formSearch").submit();
        }

        function Success()
        {
            var txt = $("#SearchTitle").val().trim();
            if (txt.length > 0)
            {
                $(".title").each(function ()
                {
                    var newTxt = $(this).html().replace(txt, txt.fontcolor("red"));
                    $(this).html(newTxt);
                });
            }
            $("input[name='PageSize']").val('@ViewData["NowPageSize"]');
            $("#PageSize").val(@ViewData["NowPageSize"]);
        }
    </script>
</body>
</html>
